#ifndef _SCREENMANAGER_H_
#define _SCREENMANAGER_H_

#include "EntityView.h"
#include "ShipView.h"
#include "BaseView.h"
#include "..\sdl\SDLSurface.h"
#include "..\..\GameModel\model\Entity.h"
#include "..\..\GameModel\model\ISceneObserver.h"
#include "..\..\GameModel\model\Constants.h"
#include "..\..\GameModel\model\Ship.h"
#include "..\..\GameModel\model\Base.h"
#include "..\..\GameBootstrap\concurrent\Lock.h"
#include "..\..\Util\Logger.h"
#include "..\..\Util\Utils.h"
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <algorithm>

using namespace view;
using namespace util;

namespace view
{
class ScreenManager : public ISceneObserver
{
public:
	ScreenManager(sdl::SDLSurface* surface, std::string backgroundImage);
	ScreenManager(sdl::SDLSurface* surface);
	~ScreenManager(void);
	void render(void);

	// Metodos de la interfaz ISceneObserver
	void newEntity(model::Entity* entity, int width, int height);
	void newEntity(model::Entity*);
	void removedEntity  (model::Entity*);
	int  getEntityWidth (model::Entity*);
	int  getEntityHeight(model::Entity*);
	void activatePolygonView(void);
	void onlyPolygonView(void);
private:	
	void clearPendingEntities(void);
	void renderFirstScreen(void);
	concurrent::Mutex mutex;
	SDLSurface* surface;
	SDLSurface* intro;
	SDLSurface* background;
	std::string backgroundImage;
	vector<EntityView*> entityviews;
	list<EntityView*> pendingToDelete;
	map<int, EntityView*> mapEntityview;
	bool firstRender, polygonView, onlyPolygon;
	int maxEntityWidth, maxEntityHeight;
};
};

#endif
